<#include "/common/_layout.html"> <#assign pageJavascript>
<script type="text/javascript">
var delit = function(obj){
	var tr = $(obj).parent().parent("tr").attr("id");
	var id = tr.replace("tr_","");
	listPage.deleteTr(tr,id);
};
var delitall = function(){
	var ids = "";
	$("#showlist").find("input:checked").each(function(){
		ids += "'"+$(this).val()+"',";
	});
	if(ids.length>0){
		listPage.deleteTrs(ids.substr(0,ids.length-1));
	}
};
$(function(){
	  $(".cheall").click(function () {
	        if ($(".cheall").is(':checked')) {
	           $("tr :checkbox").prop("checked", "checked");
	        }
	        else {
	        	$("tr :checkbox").prop("checked",false);
	        }
	    });
	listPage.config = {listUrl:"/admin/system/message/profile",delUrl:"/admin/system/message/delete"};
	listPage.showlist = function(data){
		if(data.list == undefined) return false;
		$("#showlist").empty();
		$.each(data.list, function (i, row) {
			switch(row.btype)
			{
			case 1: medalv = "官方消息"; break;
			case 2: medalv = "电器故障"; break;
			case 3: medalv = "电池断开"; break;
			case 4: medalv = "电量过低"; break;
			case 5: medalv = "车辆移动"; break;
			case 6: medalv = "车辆倾倒"; break;
			default:
			 medalv = "未知类别";
			}
			var str = '<tr id="tr_'+row.id+'"><td><input type="checkbox" value="'+row.id+'" class="tr_c" name="tr_'+row.id+'" id="tr_'+row.id+'" /></td><td>'+row.id+'</td><td class="hidden-xs">'+row.title+'</td><td>'+row.intime+'</td><td>'+row.details+'</td><td>'+medalv+'</td><td>'+row.mac+'</td><td>'
			<#if session.usermodels?index_of(",2_2,")&gt;-1 > 
			+'<a class="btn btn-primary btn-xs" href="/admin/system/message/edit/'+row.id+'">查看详情</a>'
			</#if>
			<#if session.usermodels?index_of(",2_3,")&gt;-1 > 
			+'&nbsp;<button class="btn btn-danger btn-xs" onclick="delit(this)">删除</button>'
			</#if>
			+'</td></tr>';
			$("#showlist").append(str);
		});
		$("#page").page({total:data.totalRow,currentpage:data.pageNumber,gopage:listPage.gopage,pagesize:data.pageSize});
	};
	$("#querybtn").click(function(){
		listPage.gopage(10,1);
	});
	$("#querybtn").click();	
});
</script>
</#assign> <#assign pageCss>
<style type="text/css">
</style>
</#assign> <@layout pageTitle="消息管理" pageJavascript=pageJavascript
pageCss=pageCss>
<h3 class="page-header">消息管理</h3>
<div class="panel panel-default">
	<div class="panel-body filter">
		<div class="form-inline">
			<div class="form-group">
				<label for="title">消息标题：</label> <input type="text"
					class="form-control" id="title" data-rule="like"> <label
					for="btype">消息类别：</label> <select id="btype" data-rule="eq"
					class="form-control">
					<option value=" ">所有类别</option>
					<option value="1">官方消息</option>
					<option value="2">电器故障</option>
					<option value="3">电池断开</option>
					<option value="4">电量过低</option>
					<option value="5">车辆移动</option>
					<option value="6">车辆倾倒</option>
				</select> <label>发送时间：</label> <input class="form-control"
					style="width: 160px"
					onFocus="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
					type="input" data-rule="ge" id="start_intime">～ <input
					class="form-control" style="width: 160px"
					onFocus="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
					type="input" data-rule="le" id="end_intime">
			</div>
			<button id="querybtn" class="btn btn-default">查询</button>
			<button class="btn btn-danger" onclick="delitall()">批量删除</button>
		</div>
	</div>
</div>
<table class="table table-bordered table-hover table-striped">
	<thead>
		<tr>
			<th width="50px"><input type="checkbox" name="cheall"
				class="cheall" id="tr_" /><label for="tr_">全选</label></th>
			<th width="90px">消息id</th>
			<th width="90px" class="hidden-xs">消息标题</th>
			<th width="90px">消息时间</th>
			<th width="180px">消息详情</th>
			<th width="90px">消息类别</th>
			<th width="90px">mac</th>
			<th width="90px">操作</th>
		</tr>
	</thead>
	<tbody id="showlist"></tbody>
</table>
<nav>
	<ul id="page" class="pagination"></ul>
</nav>
</@layout>
